<?php


/*
 * Lấy thông tin và hình của 1 album dựa vào id của album
 * Return:
 *  Array :  aid , 
 *          voc, 
 *          album_name, 
 *          album_description, 
 *          images (Array) : fid, image_name, sum_like, source_thumbnail, source_fullsize, source_share, source, 
 *          url_custom, description
 */
function api_tbalbum_get_by_aid($aid) {
    $data = array();
    $result = api_get_images_list($aid);

    $album = api_get_album($aid);
   
    $data['aid'] = $aid;
    
    $data['name'] = $album->name;
    $data['description'] = $album->description;
    $data['type_link'] = 'TB_ALBUM';
    
    $items = array();
    foreach ($result as $record) {
        $items[] = array(
            'fid' => $record->fid,
            'aid' => $aid,
            'voc' => $album->vo_id,
            'owner_id' => $record->uid,
            'image_name' => $record->image_name,
            'sum_like' => $record->sum_like,
            'source_thumbnail' => str_replace('album_big', 'album_thumb', $record->url_custom),
            'source_fullsize' =>str_replace('album_big', 'album_large', $record->url_custom),
            'source_share' => str_replace('album_big', 'album_wall', $record->url_custom),
            'source' => $record->source,
            'original' => $record->url_custom,
            'url_custom' => $record->url_custom,
            'description' => $record->description,
        );
    }

    $data['images'] = $items;
    
    return $data;
    
    
}
